package cn.echo.modules.sys.service;


import cn.echo.common.baseservice.BaseService;
import cn.echo.modules.sys.dao.SiteMapper;
import cn.echo.modules.sys.entity.Site;
import cn.echo.modules.sys.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service//让service成为组件(对象) 可以装配(注入)
public class SiteService extends BaseService {
   /* @Autowired
    private SqlSession session;*/
    @Autowired
    private SiteMapper siteMapper;//注入mapper对象
    public List<Site> findAll(Site site) {

        List<Site> siteList = siteMapper.findAll(new Site());
//        session.close();
        return siteList;
    }

    public Site findById(Site site) {

        return siteMapper.findByIdReturnByResultMap(site);

    }

    public boolean update(Site site) {

        boolean flag = false;
        try {
            site.setUpdateDate(new Date());
            flag = siteMapper.updateById(site);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

}